home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / system-config-printer / gtkspinner.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-10-28  |  2KB  |  72 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import glib
  5. import gtk
  6.  
  7. class Spinner:
  8.     
  9.     def __init__(self, image):
  10.         self.image = image
  11.         frames = []
  12.         theme = gtk.icon_theme_get_default()
  13.         icon_info = theme.lookup_icon('process-working', 22, 0)
  14.         if icon_info != None:
  15.             size = icon_info.get_base_size()
  16.             icon = icon_info.get_filename()
  17.             
  18.             try:
  19.                 pixbuf = gtk.gdk.pixbuf_new_from_file(icon)
  20.                 grid_width = pixbuf.get_width()
  21.                 grid_height = pixbuf.get_height()
  22.                 y = 0
  23.                 while y < grid_height:
  24.                     x = 0
  25.                     while x < grid_width:
  26.                         frame = pixbuf.subpixbuf(x, y, size, size)
  27.                         frames.append(frame)
  28.                         x += size
  29.                     y += size
  30.             except gobject.GError:
  31.                 pass
  32.             except:
  33.                 None<EXCEPTION MATCH>gobject.GError
  34.             
  35.  
  36.         None<EXCEPTION MATCH>gobject.GError
  37.         self.frames = frames
  38.         self.n_frames = len(frames)
  39.         self._rest()
  40.  
  41.     
  42.     def _set_frame(self, n):
  43.         self._current_frame = n
  44.         if self.n_frames == 0:
  45.             self.image.clear()
  46.             return None
  47.         self.image.set_from_pixbuf(self.frames[n])
  48.  
  49.     
  50.     def _rest(self):
  51.         self._set_frame(0)
  52.  
  53.     
  54.     def _next_frame(self):
  55.         n = self._current_frame + 1
  56.         if n >= self.n_frames:
  57.             n = 0
  58.         
  59.         self._set_frame(n)
  60.         return True
  61.  
  62.     
  63.     def start(self, timeout = 125):
  64.         self._task = glib.timeout_add(timeout, self._next_frame)
  65.  
  66.     
  67.     def stop(self):
  68.         glib.source_remove(self._task)
  69.         self._rest()
  70.  
  71.  
  72.